<?php
namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class SpecCategory extends Base
{
    use SoftDelete;

    // 设置当前模型的数据库连接
    public function pName(){
        return $this->hasOne("SpecCategory","id","pid")->bind(['pid_name'=>"name"]);
    }


    // 创建分类树
    public function treeList($where)
    {


//        $list = cache('DB_TREE_SPEC');
//        if(!$list){

            $list = $this->where($where)->order('sort ASC,id ASC')->select();
            $treeClass = new \expand\Tree();
            $list = $treeClass->create($list);

//            cache('DB_TREE_SPEC', $list);
//        }
        return $list;

    }



}